<template>
	<view class="money" v-if="show" @click="hideDialog">
		<image src="@/static/bag.png" mode="widthFix"></image>
		<view class="black">
			<view class="left">
				<view class="bg" :style="{transform: 'rotate('+l_rotate+'deg)'}"></view>
			</view>
			<view class="right">
				<view class="bg" :style="{transform: 'rotate('+r_rotate+'deg)'}"></view>
			</view>
		</view>
	</view>
</template>

<script>
	let t;
	export default {
		props:["time"],
		data() {
			return {
				show: false,
				l_rotate:0,
				r_rotate:0
			}
		},
		onLoad() {
			
		},
		methods: {
			showDialog() {
				this.show = true;
				this.l_rotate = 0;
				this.r_rotate = 0;
				this.cutTime();
			},
			hideDialog() {
				this.show = false;
				clearInterval(t);
			},
			// 倒计时
			cutTime(){
				var that = this;
				t = setInterval(function(){
					var a = that.l_rotate;
					var b = that.r_rotate;
					if(a == 0 && b >= 0 && b <180){
						that.r_rotate++;
					}
					if(a >= 0 && a < 180 && b == 180){
						that.l_rotate++;
					}
					if(a == 180 && b == 180){
						clearInterval(t);
					}
				},that.time*1000/360)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.money {
		position: absolute;
		left: 10rpx;
		top: 40%;
		width: 100rpx;
		text-align: center;
		image {
			width: 50rpx;
		}
		
		.black {
			position: absolute;
			left: 10rpx;
			top: -10rpx;
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			.left{
				position: absolute;
				width: 80rpx;
				height: 80rpx;
				transform: rotate(0deg);
				clip: rect(0rpx,40rpx,80rpx,0rpx);
				border-radius: 50%;
				overflow: hidden;
			}
			.right{
				position: absolute;
				width: 80rpx;
				height: 80rpx;
				transform: rotate(-180deg);
				clip: rect(0rpx,40rpx,80rpx,0rpx);
				border-radius: 50%;
				overflow: hidden;
				
			}
			.bg{
				position: absolute;
				width: 80rpx;
				height: 80rpx;
				clip: rect(0rpx,40rpx,80rpx,0rpx);
				border-radius: 50%;
				background: rgba($color: #000000, $alpha: 0.5);
			}
		}

	}
</style>
